home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 20 / Cream of the Crop 20 (Terry Blount) (1996).iso / program / kh_gdi.zip / KH_GDI / BGI_FONT.H < prev    next >
C/C++ Source or Header  |  1996-05-09  |  3KB  |  61 lines

  1. #ifndef __BGI_FONT_H_
  2. #define  __BGI_FONT_H_
  3.  
  4. /*  Class incapsulate BGI fonts (*.chr) description.
  5.     1. BGI fonts are not documented. I use existing format.
  6.     2. Abstract (non-BGI) graphics is used for moveto, lineto, drawpoly and
  7.        fillpoly operations. It should be overloaded in child classes for
  8.        concrete graf. libraries like BGI, Windows GDI and so on.
  9.     3. BGI header have some fields, which are not absolutely necessary. I
  10.        skip them and remarks are not complete for them.
  11.     4. No facilities like "vertical text" and so on is supported.
  12.        The reason is: I suppose to use drawing extender which have rotation
  13.        possibilities.
  14. */
  15.  
  16. #include "kh_gdi\abs_graf.h" // Abstract graphics, functions shablones for lineto(),
  17.               // moveto(), drawpoly() and fillpoly()
  18.  
  19.  
  20. struct _export BGI_Font : public AbstractGraphics
  21.     {
  22.     int h_just, v_just;   // LEFT_TEXT 0, CENTER_TEXT 1, RIGHT_TEXT 2
  23.     // BGI Font Prefix
  24.     int HeaderSize;           // ...
  25.     int FontSize;             // Font without header
  26.     // BGI Font descriptor
  27.     uchar SymbolsInFont;      // Usually start from ' '
  28.     uchar FirstSymbol;        // Usually start from ' '
  29.     int StrokesOffset;        // Characters descriptions offset
  30.     char FillFlag;            // Fill or not, default 0
  31.     uchar CapitalHeight;      // ...
  32.     uchar BaseLine;           // Usually 0
  33.     uchar Descender;          // for y, g and other
  34.     // BGI Tables
  35.     int* OffsetTable;         // Offsets of symbols descriptions
  36.     char* WidthTable;         // ...
  37.     char* vectors;
  38.  
  39.     static char* buffer;
  40.     int* polypoints;          // Used only for filled fonts.
  41.  
  42.     uchar multx, multy, divx, divy;   // Deformation for setusercharsize()
  43. //////////////////////////////// Functions ///////////////////////////////////
  44.     BGI_Font(char* fileName = 0);  // Create object and load() font. Set
  45.                    // kh_error_code in the case of error
  46.     ~BGI_Font();
  47.  
  48.     void load(char* fileName);     // Remove old and load new font
  49.  
  50.     int draw_char(int x, int y, char c, int dir = 0);
  51.     int outtextxy(int x, int y, char* str, int dir = 0);
  52.     void outtext(char* str) {} // Overload when CP specified
  53.  
  54.     int gettextwidth(char*  str);
  55.     int getheight() { return CapitalHeight; }
  56.     void setusercharsize(int mx, int dx, int my, int dy)
  57.     { multx = mx; multy = my; divx = dx; divy = dy; }
  58.     void settextjustify(int j, int k) { h_just = j; v_just = k; }
  59.     };
  60.  
  61. #endif __BGI_FONT_H_